
$(function() {
	Tip.supplier();
	
	$('#supplier').blur(function() {		
		var a = $(this).val();
		
		var body = { };
		body.id = a;
		$.getJSON('contact.php?do=Supplier.ajax_id', body, function(json) {
			$("#c_name").val(json.name);
			$("#c_fullname").val(json.fullname);
			$("#c_address").val(json.address);
			$("#c_web").val(json.url);
		});
		
		var body = { };
		body.id = a;
		$.getJSON('contact.php?do=Supplier.ajax_id', body, function(json) {
			$("#currency").val(json.currency);
			$("#type").val(json.pay);
			$("#rate").val(json.rate);
		});
		
		_supplier(a);
	});
	
	$("#label_linkman").hide();
	
	$('#currency').change(function() {
		var a = $("#cost").val();
		var b = $(this).find("option:selected").text();
	
		Currency.upper(a, b, "#label_amount");
	});
	
	$('#cost').keyup(function() {
		var a = $(this).val();
		var b = $("#currency").find("option:selected").text();
		Currency.upper(a, b, "#label_amount");
	});
	
	$('input[id^=et]:visible').datepicker(_date1_option);
	$('#date').datepicker(_date1_option);
	
	$("input[id='emp']:visible").autocomplete(Test.emp);
	
	_ck_default("input[id='emp']:visible", "input[id^='emp_t']:visible");

	$('textarea').css("width", 350);
});

function _supplier(a) {
	var body = {};
	body.q = a;
	
	$.getJSON('finanace.php?do=PaymentMy.ajax_linkman', body, function(json) {			
		Supplier.linkman(json);
	});
}